<?php

/**
 * Product Form
 *
 * @category   Cms
 * @package    Cms_Form
 */

class Cms_Form_Catalog_Product_Form extends BIS_Form_Abstract
{
    public function init()
    {
        
        $this->addElementPrefixPath('Cms_Decorator',
                            	     APPLICATION_PATH . '/modules/cms/models/decorator/',
                            	    'decorator');

        $this->setMethod('post');
        $this->setAction('');
        $this->setModel(new Cms_Model_Catalog());


        // get the select
        $form = new Cms_Form_Catalog_Category_Select(
            array('model' => $this->getModel())
        );
        $element = $form->getElement('categoryId');
        $element->clearDecorators()->loadDefaultDecorators();
        $element->clearFilters();
        $element->setRequired(true);
        $this->addElement($element);

        $this->addElement('text', 'name', array(
            'label' => 'Product Name',
            'size' => 30,
            'filters' => array('StringTrim'),
            'required' => true
        ));

        $this->addElement('textarea', 'description', array(
            'label' => 'Product Description',
            'rows' => 5,
            'cols' => 50,
            'filters' => array('StringTrim'),
            'validators' => array(array('StringLength',true, array(1,255)))
        ));
        
        $this->addElement('text', 'discountPercent',array(
        		'label' => 'Discount %',
        		'size' => 5,
        		'filters' => array('Null'),
        		'validators' => array('Int')
        ));
        
        $this->addElement('text', 'vatPercent',array(
        		'label' => 'Vat %',
        		'size' => 5,
        		'filters' => array('Null'),
        		'validators' => array('Int')
        ));

        $this->addElement('text', 'manufacturer',array(
            'label' => 'Manufacturer',
            'size' => 30
        ));

        $this->setElementDecorators(array(
            'ViewHelper',
            'FormElementsErrors',
             array(array('data' => 'HtmlTag'),  array('tag' =>'td')),
              'FormElementsLabel',
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class'=> 'form')),
            'Form'
        ));
    }
}